package worker;

import java.util.Set;
import java.util.concurrent.BlockingQueue;

public class StringSearch extends AbstractSearch {
	
	public StringSearch(BlockingQueue<String> queue, Set<String> searchSet) {
		super(queue,searchSet);		
	}

	@Override
	public String call() throws Exception {
		StringBuffer buffer = new StringBuffer();
		init();
		String url = null;
		synchronized(urlQueue){
			url= urlQueue.poll();
		}
		if(url!= null) {
			download(url);
			buffer.append("FileName = " + localFileName());
			search();
			buffer.append(" "+ this.counter.toString());
		}
		return buffer.toString();
	}
	private String localFileName(){
		return this.localFile.substring(localFile.indexOf("/"));
	}
}
